<?php
include "includes/bootstrap.php";

if (isset($_GET['category'])) {
	$category = $_GET['category'];
} else {
	$category = "";
}

if (isset($_GET['start'])) {
	$start = $_GET['start'];
} else {
	$start = "0";
}

if (isset($_GET['limit'])) {
	$limit = $_GET['limit'];
} else {
	$limit = "5";
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Post a link</title>

<link href="themes/default/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="includes/css/style.css" type="text/css" media="screen" title="no title" charset="utf-8">
<script src="includes/js/jquery-1.2.js" type="text/javascript" charset="utf-8"></script>
<script src="includes/js/jquery.form.js" type="text/javascript" charset="utf-8"></script>
<script src="includes/js/index.js" type="text/javascript" charset="utf-8"></script>

</head>

<body class="bd">
<div id="overcontainer">
<div id="container">
  <div id="header">
    <h3><a href="index.php" style="color: black; text-decoration: none">Post-a-link</a></h3>
    <!-- end #header --></div>
  <div id="mainContent">
		<div id="notifications" style="display: none;"><?php echo notifications(); ?></div>
	  <form method="post" id="addLinkForm">
  
    <h3>Add a link</h3>
					<?php
					$list = new Lister();
					$list->category_selectbox("id", "category");
					?>
			<br />
      <label>Title
      <input type="text" name="title" id="title" />
      </label><br />
      <label>URL
      <input type="text" name="url" id="url" value="http://" />
      </label><br />
      <label>Description
      <input type="text" name="description" id="description" value="" />
      </label><br />
      <label>
			<input type="hidden" name="add_link" value="Add link" />
      <input type="submit" value="Add Link" />
      </label>
    </form>

    <form id="addCategoryForm" name="form2" method="post" action="process.php">

    <h3>Add a category</h3>
      <label>Name
      <input type="text" name="category_name" id="category_name" value="" />
      </label>
      <label>
				<input type="hidden" name="add_category" value="Add category" />
	
      <input type="submit" name="add_category" id="add_category" value="Add category" />
      </label>
    </form>

		<div style="clear:both;"></div>	
		
		<div id="categories">

			<h3>Categories</h3>
			<?php
			$list->categories();
			?>
		</div>
		<div id='filters'>
			<form action="index.php" method="get">
				<?php
				$list = new Lister();
				$list->category_selectbox("name", "categoryFilter");
				?>
				Limit
				<select name="limit" id="limit">
					<option value="<?php if(isset($limit)) { echo $limit; } else { echo "5"; }?>"><?php if(isset($limit)) { echo $limit; } else { echo "5"; }?></option>
					<option value="5">5</option>
					<option value="10">10</option>
					<option value="20">20</option>
					<option value="50">50</option>
				</select>
				


				<input type="submit" name="filter" id="filter" value="Submit" />
			</form>

		</div>
		<div id="links">
			<?php $list->links_for_category("name", $category, $start, $limit); ?>

		</div>

	<!-- end #mainContent --></div>
  <div id="footer">
    <p>Yoursite is super cool.</p>
  <!-- end #footer --></div>
<!-- end #container --></div>
		</div>
</body>
</html>
